package java模板模式;

/**
 * @author coderFu
 * @create 2022/3/4
 * 构造函数实际应用 jvm中对象的销毁
 */
public class ActuallyApplication {

    public static void main(String[] args) {


        //定义线程1
        Thread thread = new Thread(()->{
            System.out.println("thread1....");
        });

        //定义线程2
        Thread thread2 = new Thread(()->{
            System.out.println("thread2....");
        });

        //定义线程1
        Thread shutdownThread = new Thread(()->{
            System.out.println("shutdownThread....");
        });


        // 将该钩子添加到jvm中,在jvm执行结束前会先执行钩子
        Runtime.getRuntime().addShutdownHook(shutdownThread);

        thread.start();
        thread2.start();
    }


}
